<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*,util.*"%>
<%
	PhaseModel obj;
	Object temp = request.getAttribute("phase");
	if (temp != null) {
		try {
			obj = (PhaseModel) temp;
		} catch (Exception ex) {
			obj = new PhaseModel();
		}
	} else {
		obj = new PhaseModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Phase</title>

<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css"
	type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css"
	type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" />

<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.ui.widget.min.js"></script>

<script language="javascript" type="text/javascript"
	src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript"
	src="js/ajaxQuickInsert.js"></script>

<link rel="stylesheet" href="css/inputForm.css" />

<script language="javascript" type="text/javascript">
	var requiredInputs = [['name','name_required'],['code','code_required'],['description','description_required'],['status','status_required'],['plan_start_date','plan_start_date_date_required', 'plan_start_date','plan_start_date_time_required'],['plan_end_date','plan_end_date_date_required', 'plan_end_date','plan_end_date_time_required'],['real_start_date','real_start_date_date_required', 'real_start_date','real_start_date_time_required'],['real_end_date','real_end_date_date_required', 'real_end_date','real_end_date_time_required']];
	var intInputs = [['id_project','id_project_invalid'],['status','status_invalid']];
	var doubleInputs = [];
	var dateInputs = [['plan_start_date','plan_start_date_date_invalid'],['plan_end_date','plan_end_date_date_invalid'],['real_start_date','real_start_date_date_invalid'],['real_end_date','real_end_date_date_invalid']];
	var timeInputs = [['plan_start_date','plan_start_date_time_invalid'],['plan_end_date','plan_end_date_time_invalid'],['real_start_date','real_start_date_time_invalid'],['real_end_date','real_end_date_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<jsp:include page="menu.jsp"></jsp:include>
	<br />
	<table>
		<tr>
			<td>
				<form action="phase?mode=insert" method="post"
					onSubmit="return checkInputs()"
					onreset="return confirm('Do you really want to reset the form?')">
					<table class="tblInput" border="1">
						<tr class="inputHeader">
							<th colspan="3" class="inputHeader">Create New Phase</th>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput"><input class="inputText"
								type="text" id="name" name="name" maxlength="255"
								value="<%=obj.getNameToString()%>" /></td>
							<td class="tdErrMsg"><span id="name_required" class="errMsg"
								style="display: none;">Name is required</span> <span
								id="name_invalid" class="errMsg" style="display: none;">Name
									is invalid</span> <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Code</td>
							<td class="tdFieldInput"><input class="inputText"
								type="text" id="code" name="code" maxlength="20"
								value="<%=obj.getCodeToString()%>" /></td>
							<td class="tdErrMsg"><span id="code_required" class="errMsg"
								style="display: none;">Code is required</span> <span
								id="code_invalid" class="errMsg" style="display: none;">Code
									is invalid</span> <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput"><textarea id="description"
									name="description" rows="5" class="inputTextarea"><%=obj.getDescriptionToString()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="description_required"
								class="errMsg" style="display: none;">Description is
									required</span> <span id="description_invalid" class="errMsg"
								style="display: none;">Description is invalid</span> <span
								id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id Project</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id_project" name="id_project" maxlength="10"
								value="<%=obj.getIdProjectToString()%>" /></td>
							<td class="tdErrMsg"><span id="id_project_required"
								class="errMsg" style="display: none;">Id Project is
									required</span> <span id="id_project_invalid" class="errMsg"
								style="display: none;">Id Project is invalid</span> <span
								id="id_project_error" class="errMsg"><%=obj.errMsgs.IdProject%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Status</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="status" name="status" maxlength="10"
								value="<%=obj.getStatusToString()%>" /></td>
							<td class="tdErrMsg"><span id="status_required"
								class="errMsg" style="display: none;">Status is required</span>
								<span id="status_invalid" class="errMsg" style="display: none;">Status
									is invalid</span> <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Plan Start Date</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="plan_start_date_date"
											name="plan_start_date_date"
											value="<%=StringUtil.toDateTimeString(obj.getPlanStartDate())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('plan_start_date_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="plan_start_date_time"
											name="plan_start_date_time"
											value="<%=obj.getPlanStartDate()%>" /></td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="plan_start_date_error"
								class="errMsg"><%=obj.errMsgs.PlanStartDate%></span>
								<div class="divErr">
									<span id="plan_start_date_date_required" class="errMsg"
										style="display: none;">Plan Start Date's date is
										required</span>
								</div>
								<div class="divErr">
									<span id="plan_start_date_time_required" class="errMsg"
										style="display: none;">Plan Start Date's time is
										required</span>
								</div>
								<div class="divErr">
									<span id="plan_start_date_date_invalid" class="errMsg"
										style="display: none;">Plan Start Date's date is
										invalid</span>
								</div>
								<div class="divErr">
									<span id="plan_start_date_time_invalid" class="errMsg"
										style="display: none;">Plan Start Date's time is
										invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Plan End Date</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="plan_end_date_date"
											name="plan_end_date_date"
											value="<%=StringUtil.toDateTimeString(obj.getPlanEndDate())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('plan_end_date_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="plan_end_date_time"
											name="plan_end_date_time" value="<%=obj.getPlanEndDate()%>" />
										</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="plan_end_date_error"
								class="errMsg"><%=obj.errMsgs.PlanEndDate%></span>
								<div class="divErr">
									<span id="plan_end_date_date_required" class="errMsg"
										style="display: none;">Plan End Date's date is required</span>
								</div>
								<div class="divErr">
									<span id="plan_end_date_time_required" class="errMsg"
										style="display: none;">Plan End Date's time is required</span>
								</div>
								<div class="divErr">
									<span id="plan_end_date_date_invalid" class="errMsg"
										style="display: none;">Plan End Date's date is invalid</span>
								</div>
								<div class="divErr">
									<span id="plan_end_date_time_invalid" class="errMsg"
										style="display: none;">Plan End Date's time is invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Real Start Date</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="real_start_date_date"
											name="real_start_date_date"
											value="<%=StringUtil.toDateTimeString(obj.getRealStartDate())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('real_start_date_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="real_start_date_time"
											name="real_start_date_time"
											value="<%=obj.getRealStartDate()%>" /></td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="real_start_date_error"
								class="errMsg"><%=obj.errMsgs.RealStartDate%></span>
								<div class="divErr">
									<span id="real_start_date_date_required" class="errMsg"
										style="display: none;">Real Start Date's date is
										required</span>
								</div>
								<div class="divErr">
									<span id="real_start_date_time_required" class="errMsg"
										style="display: none;">Real Start Date's time is
										required</span>
								</div>
								<div class="divErr">
									<span id="real_start_date_date_invalid" class="errMsg"
										style="display: none;">Real Start Date's date is
										invalid</span>
								</div>
								<div class="divErr">
									<span id="real_start_date_time_invalid" class="errMsg"
										style="display: none;">Real Start Date's time is
										invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Real End Date</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="real_end_date_date"
											name="real_end_date_date"
											value="<%=StringUtil.toDateTimeString(obj.getRealEndDate())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('real_end_date_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="real_end_date_time"
											name="real_end_date_time" value="<%=obj.getRealEndDate()%>" />
										</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="real_end_date_error"
								class="errMsg"><%=obj.errMsgs.RealEndDate%></span>
								<div class="divErr">
									<span id="real_end_date_date_required" class="errMsg"
										style="display: none;">Real End Date's date is required</span>
								</div>
								<div class="divErr">
									<span id="real_end_date_time_required" class="errMsg"
										style="display: none;">Real End Date's time is required</span>
								</div>
								<div class="divErr">
									<span id="real_end_date_date_invalid" class="errMsg"
										style="display: none;">Real End Date's date is invalid</span>
								</div>
								<div class="divErr">
									<span id="real_end_date_time_invalid" class="errMsg"
										style="display: none;">Real End Date's time is invalid</span>
								</div></td>
						</tr>

						<tr class="trInputBottom">
							<td class="tdInputBottom" colspan="3">
								<table class="tblSubmit" align="center">
									<tr class="trSubmit">
										<td class="tdSubmit"><input type="submit" value="Submit" />
										</td>
										<td class="tdReset"><input type="reset" value="Reset" />
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</form></td>
		</tr>
	</table>
	<br />
	<jsp:include page="phaseList.jsp?embedded=true"></jsp:include>
</body>
</html>